/**
 * @author LKQ
 * @date 2022/2/24 12:05
 * @description 递归
 */
public class Solution {
    public static void main(String[] args) {

    }
    public boolean isSubPath(ListNode head, TreeNode root) {
        if (head == null) {
            return true;
        }
        if (root == null) {
            return false;
        }
        //先判断当前的节点，如果不对，再看左子树和右子树呗
        return isSub(head, root) || isSubPath(head, root.left) || isSubPath(head, root.right);
    }
    public boolean isSub(ListNode head, TreeNode root) {
        if(head == null) {
            // 链表判断到空，
            return true;
        }
        if(root == null) {
            // 链表不为空，root为空了
            return false;
        }
        if(head.val != root.val) {
            return false;
        }
        return isSub(head.next, root.left) || isSub(head.next, root.right);
    }
}
